﻿using UnityEngine;
using System.Collections;

public class LineMover : MonoBehaviour {



    private Vector3 velocityBak;


    public void go(bool isUp = true, float angle = 0,float v = 12.0f){

        float radians = Mathf.PI * angle / 180.0f;
        float a2 = Mathf.Tan(radians);


        GetComponent<SpriteRenderer>().flipY = !isUp;
        GetComponent<Rigidbody2D> ().velocity = 
            new Vector3(v*a2,(isUp?1:-1)*v, 0);
            
    }

    public void stop() {
        GetComponent<Rigidbody2D>().velocity = Vector3.zero;
    }

    public void pause() {
        velocityBak = GetComponent<Rigidbody2D>().velocity;
        stop();
    }

    public void resume() {
        GetComponent<Rigidbody2D>().velocity = velocityBak;
    }

}
